home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1996-01-26 | 3.3 KB | 96 lines |
- ' ********************************************************
- ' *** ***
- ' *** Input Text Procedure ***
- ' *** ***
- ' *** by ***
- ' *** ***
- ' *** Joseph Bolin ***
- ' *** ***
- ' ********************************************************
- Screen Open 0,320,200,8,Lowres
- Palette $0,$FFF,$444,,$F00 : Curs Off : Cls 2
- _INPUT[64,96,64,24,"Enter some text here:",1,0,3]
- _INPUT[60,108,64,24,"Another example of this input routine",4,0,3]
-
-
- Procedure _INPUT[_XPOS,_YPOS,_LENGTH,_SHOW,_DEFAULT$,_PEN,_PAPER,_CURSPEN]
-
- ' Replacement for the input command; May be at any position on the screen
- '
- '
- ' Inputs: _XPOS,_YPOS Coordinates of input; Not limited to mutiples of 8
- ' _LENGTH Maximum length of string
- ' _SHOW Length of shown section
- ' _DEFAULT$ Default reply
- ' _PEN Color of text
- ' _PAPER Background of text
- ' _CURSPEN Color of cursor
- '
- ' Output: Param$ Inputed string
-
- INP$=_DEFAULT$
- SPOS=Len(INP$)+1-_SHOW : CPOS=Min(_SHOW-1,Len(INP$))
- If SPOS<0 Then SPOS=0
- Do
- Ink _PEN,_PAPER
- Text _XPOS,_YPOS+Text Base,Left$(Mid$(INP$,SPOS+1,_SHOW-1)+Space$(_SHOW),_SHOW)
- Ink _CURSPEN : Bar _XPOS+CPOS*8,_YPOS+6 To _XPOS+CPOS*8+7,_YPOS+7
- Repeat
- KY$=Inkey$
- Until KY$<>""
- SC=Scancode : KS=Key Shift
- If KY$=Chr$(13) Then Exit
- If KY$=Chr$(29)
- If KS=0 : Gosub MLEFT : End If
- If KS and 3
- Gosub MLEFT
- Repeat
- Gosub MLEFT
- Until Mid$(INP$,SPOS+CPOS,1)=" " or SPOS+CPOS=0
- End If
- If KS and 24 : SPOS=0 : CPOS=0 : End If
- Goto DN
- End If
- If KY$=Chr$(28)
- If KS=0 : Gosub MRIGHT : End If
- If KS and 3
- Repeat
- Gosub MRIGHT
- Until Mid$(INP$,SPOS+CPOS,1)=" " or SPOS+CPOS=Len(INP$)
- End If
- If KS and 24
- SPOS=Len(INP$)+1-_SHOW : CPOS=Min(_SHOW-1,Len(INP$))
- If SPOS<0 : SPOS=0 : End If
- End If
- Goto DN
- End If
- If KY$=Chr$(8)
- If SPOS+CPOS>0 : INP$=Left$(INP$,SPOS+CPOS-1)+Right$(INP$,Len(INP$)-SPOS-CPOS) : End If
- Gosub MLEFT : Goto DN
- End If
- If SC=70
- If SPOS+CPOS<Len(INP$)
- INP$=Left$(INP$,SPOS+CPOS)+Right$(INP$,Len(INP$)-SPOS-CPOS-1)
- End If
- Goto DN
- End If
- If Len(INP$)>=_LENGTH Then Goto DN
- If KY$=Chr$(0) or KY$=Chr$(27) Then Goto DN
- INP$=Left$(INP$,SPOS+CPOS)+KY$+Right$(INP$,Len(INP$)-SPOS-CPOS)
- Gosub MRIGHT
- DN:
- Loop
- Ink _PEN,_PAPER
- Text _XPOS,_YPOS+Text Base,Left$(Mid$(INP$,SPOS+1,_SHOW-1)+Space$(_SHOW),_SHOW)
- Pop Proc[INP$]
-
- MRIGHT:
- If SPOS+CPOS=Len(INP$) Then Return
- If CPOS>(_SHOW*2)/3 and SPOS+CPOS<Len(INP$) Then Inc SPOS Else Inc CPOS
- Return
-
- MLEFT:
- If SPOS=0 and CPOS=0 Then Return
- If CPOS<_SHOW/3 and SPOS>0 Then Dec SPOS Else Dec CPOS
- Return
- End Proc